package com.atbun.orderservice.utils;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;

/**
 * @Description : 订单号生成工具
 * @Author : mayp
 * @Date: 2020-05-20 17:07
 */
public class OrderNoUtil {
//    根据时间生成订单号
    public static String getOrderNo(){
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
        String newDate = sdf.format(new Date());
        String result = "";
        Random random = new Random();
        for (int i =0;i<3;i++){
            result += random.nextInt(10);
        }
//        System.out.println(newDate+result);
        return newDate+result;
    }

    public static void main(String[] args) {
        getOrderNo();
    }
}
